@using Lombiq.BaseTheme.Core.Constants
@using Lombiq.BaseTheme.Core.Services
@using Microsoft.AspNetCore.Authorization
@using OrchardCore.Admin

@inject ICssClassHolder CssClassHolder
@inject IAuthorizationService AuthorizationService

@* This file overrides a widget content type created by a migration in Lombiq.BaseTheme and the content item added by
   the Lombiq.BaseTheme.LayersAndZones recipe. *@

@{
    // You can use ICssClassHolder to add CSS classes to the zone wrapper elements. For example this can be used to
    // add Bootstrap utility classes or shared classes across certain zones.
    CssClassHolder.AddClassToZone(ZoneNames.Footer, "text-center");
    CssClassHolder.AddClassToZone(ZoneNames.AsideFirst, "layoutAside");

    // You can also access the zone's underlying set using this method. This can be cleaner if you want to add several
    // classes. It can also be used to remove classes added by the backend (e.g. classes, services, filters), or to
    // perform any normal ISet operation on the set of classes..
    var asideSecond = CssClassHolder.GetZoneClasses(ZoneNames.AsideSecond);
    asideSecond.Add("layoutAside");
    asideSecond.Add("layoutAside_anotherClass");
    asideSecond.Remove("unwanted-class");
}

@* If you only need a site-wide style or just a handful of content-specific styles, you can inject them here. Otherwise
   you should use ResourceFilterMiddleware (see Startup.cs) and IResourceFilterProvider (see ResourceFilters.cs). You
   must use one or the other. If you use the middleware this file is optional. *@
@* <style asp-name="@ResourceNames.Site"></style> *@

@* The only reason this file has to be associated with a widget is to ensure these zones are rendered ahead of time,
   before the Layout.cshtml is invoked. Orchard Core has shape pre-rendering which outputs the zone contents into
   IHtmlContent (and replaces the zone Shape instances with PositionWrapper instances). If this file would be called
   from the Layout.cshtml would prevent adding content to a zone with the tag helper, if the zone already contained
   anything (like a conventional OC widget). By making this a widget, you can safely insert zones and resources. *@
<zone name="@ZoneNames.Header">
    <div class="navbar" id="navbar">
        <div class="navbar-brand">@Site.SiteName</div>
    </div>
    <p class="zoneInsertionExample_header">
        @T["Here you can easily inject shapes into the zones, kind of like always enabled widgets."]
    </p>
</zone>

<zone name="@ZoneNames.Footer" position="0">
    <div class="zoneInsertionExample_footer">
        @T["© {0} <a href=\"https://lombiq.com/\">Lombiq Technologies</a>", DateTime.UtcNow.Year]
    </div>
</zone>

@* You can even include shapes conditionally. In this case we want a link to the admin dashboard but only for users who
   are able to access it. Using this approach can be much easier than implementing a custom layer condition. *@
@if (await AuthorizationService.AuthorizeAsync(User, AdminPermissions.AccessAdminPanel))
{
    <zone name="@ZoneNames.Footer" position="1">
        <div class="zoneInsertionExample_footer">
            <a href="@Url.Content("~/Admin")">@T["Admin Dashboard"]</a>
        </div>
    </zone>
}

@* END OF TRAINING SECTION: Layout injection *@

@* NEXT STATION: Assets/Styles/site.scss *@
